# 精度波动数据（%）
dhaf_data = np.random.normal(85.2, 0.4, 30)  # DHA-FL：均值85.2%，标准差0.4
fedat_data = np.random.normal(83.5, 1.2, 30)  # FedAT：均值83.5%，标准差1.2

# 绘制箱线图
plt.figure(figsize=(5, 3))
box = plt.boxplot([fedat_data, dhaf_data], 
                  labels=['FedAT', 'DHA-FL'],
                  patch_artist=True,
                  widths=0.6)

# 设置箱体颜色
colors = ['#FFBE7A', '#82B0D2']
for patch, color in zip(box['boxes'], colors):
    patch.set_facecolor(color)

# 标注波动范围
# plt.text(1, 86.5, f'波动范围: ±{np.max(dhaf_data)-np.min(dhaf_data):.1f}%', 
#          ha='center', fontsize=12, color='#82B0D2')
# plt.text(1, 85.8, f'标准差: {np.std(dhaf_data):.3f}', 
#          ha='center', fontsize=10)
# plt.text(0.5, 87, f'波动范围: ±{np.max(fedat_data)-np.min(fedat_data):.1f}%', 
#          ha='center', fontsize=12, color='#FFBE7A')

plt.ylabel('Accuracy (%)', fontsize=12)
# plt.title('Model Stability under High Heterogeneity (HeteroScore>0.7)', fontsize=14)
plt.grid(axis='y', alpha=0.3)
plt.savefig('heterogeneity_stability_en.png', bbox_inches='tight')
